package com.bistu.xiong.factory.model.api.community;

import com.bistu.xiong.factory.bean.UserPost;
import com.bistu.xiong.factory.model.db.User;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * Created by XiongXiaoJun on 2017/12/15.
 * 服务器返回的所有帖子的信息
 */

public class GetUserPostRspModel {
    public static final int SEX_MAN = 1;
    public static final int SEX_WOMAN = 2;

    private String messageId;

    private String userId;

    private String portrait;

    private Integer withPicture;

    private String messagePics;

    private String username;

    private String content;

    private Integer sex;

    private Integer discussNum;

    private Integer likeNum;

    private Integer mType;

    private Integer isLike;

    private Date createTime;

    private Date updateTime;

    public GetUserPostRspModel(String messageId, String userId, String portrait, Integer withPicture, String messagePics, String username, String content, Integer sex,Integer discussNum, Integer likeNum, Integer mType, Integer isLike, Date createTime, Date updateTime) {
        this.messageId = messageId;
        this.userId = userId;
        this.portrait = portrait;
        this.withPicture = withPicture;
        this.messagePics = messagePics;
        this.username = username;
        this.content = content;
        this.sex = sex;
        this.discussNum = discussNum;
        this.likeNum = likeNum;
        this.mType = mType;
        this.isLike = isLike;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }

    public String getMessageId() {
        return messageId;
    }

    public void setMessageId(String messageId) {
        this.messageId = messageId;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getPortrait() {
        return portrait;
    }

    public void setPortrait(String portrait) {
        this.portrait = portrait;
    }

    public Integer getWithPicture() {
        return withPicture;
    }

    public void setWithPicture(Integer withPicture) {
        this.withPicture = withPicture;
    }

    public String getMessagePics() {
        return messagePics;
    }

    public void setMessagePics(String messagePics) {
        this.messagePics = messagePics;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Integer getDiscussNum() {
        return discussNum;
    }

    public void setDiscussNum(Integer discussNum) {
        this.discussNum = discussNum;
    }

    public Integer getLikeNum() {
        return likeNum;
    }

    public void setLikeNum(Integer likeNum) {
        this.likeNum = likeNum;
    }

    public Integer getmType() {
        return mType;
    }

    public void setmType(Integer mType) {
        this.mType = mType;
    }

    public Integer getIsLike() {
        return isLike;
    }

    public void setIsLike(Integer isLike) {
        this.isLike = isLike;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public UserPost toUserPost(){
        return new UserPost(new User(username,portrait,sex),content,getMessagePicsList(),discussNum,likeNum,mType,createTime,updateTime);
    }

    public List<String> getMessagePicsList(){
        return new ArrayList<>(Arrays.asList((messagePics.split(";"))));
    }
}
